use std::io::File;
use util;
use core::{Package,Manifest,SourceId};
-use util::{CargoResult, human};
+use util::{CargoResult, human, important_paths};
pub fn read_manifest(contents: &[u8], source_id: &SourceId)
-> CargoResult<(Manifest, Vec<Path>)>
pub fn read_packages(path: &Path, source_id: &SourceId)
-> CargoResult<Vec<Package>>
{
- let (pkg, nested) = try!(read_package(&path.join("Cargo.toml"), source_id));
+ let manifest = try!(important_paths::find_project_manifest_exact(path, "Cargo.toml"));
+ let (pkg, nested) = try!(read_package(&manifest, source_id));
let mut ret = vec!(pkg);
for p in nested.iter() {
FRESH, bar.display(),
COMPILING, p.root().display())));
})
+
+test!(error_message_for_missing_manifest {
+ let p = project("foo")
+ .file("Cargo.toml", r#"
+ [project]
+
+ name = "foo"
+ version = "0.5.0"
+ authors = ["wycats@example.com"]
+
+ [dependencies.bar]
+
+ path = "src/bar"
+ "#)
+ .file("src/bar/not-a-manifest", "");
+
+ assert_that(p.cargo_process("cargo-build"),
+ execs()
+ .with_status(101)
+ .with_stderr(format!("Could not find `Cargo.toml` in `{}`\n",
+ p.root().join_many(&["src", "bar"]).display())));
+
+})